Divide the sum by the number of elements.
Of course, this is assuming that there are more than zero elements. Dividing by zero causes a run-time error. Here is the program with some additional statements for computing the average of the elements:
It might look a little strange to test if array
contains any elements,
since it is obvious that it does.
However, in a more realistic program the array will come from some
external source, and sometimes the array will have length zero.
Fill in the blanks.